package com.example.demo.order;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class erfenOrder {

    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        Integer num = 0;
        do {
            list.add(num);
            num++;
        }
        while (num!=100);

        Random r = new Random(100);
        int keyNum = 99;
        System.out.println(keyNum);
        int min = 0,max = list.size()-1;
        while (min <= max){
            System.out.println("开始查找");
            int mid = min+(max-min)/2;
            if(list.get(mid) > keyNum){
                max = mid -1;
            }
            if(list.get(mid) < keyNum) {
                min = mid+1;
            }
            if(list.get(mid) == keyNum) {
                System.out.println("随机数为："+list.get(mid));
                break;
            }

        }
        System.out.println("min:"+min);

    }

}
